// Copyright (C) 2025 Kumo inc.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#include "test.hpp"

#include <rothar/pegtl/demangle.hpp>

namespace rothar
{
   template< typename T >
   void test( const std::string& s )
   {
      ROTHAR_PEGTL_TEST_ASSERT( demangle< T >() == s );
   }

   void unit_test()
   {
#if !defined( __clang__ ) && defined( __GNUC__ ) && ( __GNUC__ == 9 ) && ( __GNUC_MINOR__ <= 2 )
      // see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91155
      test< int >( "i" );
      test< double >( "d" );
      test< seq< bytes< 42 >, eof > >( "N3tao5pegtl3seqIJNS0_5bytesILj42EEENS0_3eofEEEE" );
#elif defined( _MSC_VER ) && !defined( __clang__ )
      test< int >( "int" );
      test< double >( "double" );
      // in the Microsoft world, class and struct are not the same!
      test< seq< bytes< 42 >, eof > >( "struct rothar::seq<struct rothar::bytes<42>,struct rothar::eof>" );
#else
      test< int >( "int" );
      test< double >( "double" );
      test< seq< bytes< 42 >, eof > >( "rothar::seq<rothar::bytes<42>, rothar::eof>" );
#endif
   }

}  // namespace rothar

#include "main.hpp"
